# coding=utf-8
import pymysql

from app.routes import app

conn = pymysql.connect("101.132.189.37", "root", "root", "app");
cur = conn.cursor()
@app.route('/test')
def test():
    return 'success'
@app.route('/register')
def user_register(username, password):
    sql = "insert into User (username,password) values ('%s','%s')" % (username,password)
    cur.execute(sql)
    conn.commit()
    conn.close()
@app.route('/login')
def user_login(username,password):
    sql = "select * from User where username ='%s' and password ='%s'" % (username,password)
    cur.execute()
    result = cur.fetchall()
    if len(result) == 0:
        return False
    else:
        return True